package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/1.
 */
@HttpInlet(Conn.INLET_API_MINE_ADDRESS)
public class GetApiMineAddress extends BaseAsyGet<GetApiMineAddress.Info> {
    public int userid;

    public GetApiMineAddress(AsyCallBack<GetApiMineAddress.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");


        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            JSONArray array = jsonObject.optJSONArray("data");
            for (int i = 0; i < array.length(); i++) {

                JSONObject o = array.optJSONObject(i);
                Data d = new Data();

                d.id = o.optInt("id");
                d.is_first = o.optString("is_first");
                d.rec_name = o.optString("rec_name");
                d.cur_address = o.optString("cur_address");
                d.road_address = o.optString("road_address");
                d.phone = o.optString("phone");

                info.Data.add(d);
            }
            return info;
        }


        return null;
    }

    public static class Info {

        public List<Data> Data = new ArrayList<>();
    }

    public static class Data implements Serializable {

        //        "id": "1",
//                "is_first": "true",
//                "rec_name": "小明",
//                "cur_address": "黑龙江省哈尔滨市道里区尚志街道",
//                "road_address": "尚志大街160号",
//                "phone": "13101618368"
        public int id;
        public String is_first;
        public String rec_name;
        public String cur_address;
        public String road_address;
        public String phone;
    }


}
